package com.example.mscloud.controller;

import com.example.mscloud.common.entities.Payment;
import com.example.mscloud.common.entities.result.CommonResult;
import com.example.mscloud.service.PaymentService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
public class PaymentController
{
    @Value("${server.port}")
    private int port;

    @Resource
    private PaymentService payMentService;

    @GetMapping("payment/info/normal/{id}")
    public CommonResult getInfoNormal(@PathVariable("id") Long id){
        Payment payMent = payMentService.getByIdNormal(id);
        return new CommonResult(200, "success", payMent);
    }

    @GetMapping("payment/info/timeout/{id}")
    public CommonResult getInfoTimeout(@PathVariable("id") Long id){
        Payment payMent = payMentService.getByIdTimeout(id);
        return new CommonResult(200, "success", payMent);
    }

    @GetMapping("payment/info/exception/{id}")
    public CommonResult getInfoException(@PathVariable("id") Long id){
        Payment payMent = payMentService.getByIdException(id);
        return new CommonResult(200, "success", payMent);
    }

    @GetMapping("payment/circuitBreaker/{id}")
    public CommonResult circuitBreaker(@PathVariable("id") Long id){
        Payment payMent = payMentService.circuitBreaker(id);
        return new CommonResult(200, "success", payMent);
    }

}
